Release 10.1A: OpenEdge Development:
Programming Interfaces
Releasing control resources
The following material describes the process of creating and freeing control-frame widgets. This is automatically done by the AppBuilder, but, like any other dynamic widget, you can delete a control-frame some time after you create it.
You can delete a control-frame using two techniques:
- Associate the control-frame with a widget pool in the
CREATEstatement. When you delete the widget pool, Progress deletes the control-frame widget and also releases its control-frame COM object. This is the default technique used by the AppBuilder. (The AppBuilder uses the default unnamed widget pool that is deleted when the.wends.)- Explicitly delete the control-frame using the
DELETE WIDGETstatement. This statement deletes the control-frame widget and also releases the control-frame COM object.Releasing ActiveX controls
When you delete a control-frame widget, Progress also automatically releases the control-frame COM object as well as any references to the ActiveX control held by the control-frame. You must release all other COM objects using the
RELEASE OBJECTstatement:
This example releases the control collection after it is no longer needed. It also deletes the control-frame using the
DELETE WIDGETstatement, which also releases the chCtrlFrame COM object as well as the ActiveX control itself (chCSSpin).Releasing COM objects individually
If you try to release an ActiveX control (using the
RELEASE OBJECTstatement) before the control-frame is deleted, this works but is unnecessary. If you try to access a control after the control-frame is deleted, Progress displays an error message that you are trying to reference an invalid component handle.Because you have a component handle to a control-frame COM object, you might think you can release it using the
RELEASE OBJECTstatement. However for control-frame COM objects, Progress does not allow this because of the link between the control-frame widget and COM object.Thus, you can only release the control-frame COM object by deleting the control-frame widget. If you do try to release the component handle of a control-frame, Progress returns an error indicating that you should delete the object through the widget handle instead.
In general, if you do not delete or release any COM objects in an application, all active COM objects remain instantiated until the end of the OpenEdge session, at which time Progress automatically releases them.
For more information on releasing COM object resources, see Chapter 14, " Using COM Objects in the 4GL."
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |